/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author WinKiQue58
 */
@Entity
@Table(name = "POINT")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Point.findAll", query = "SELECT p FROM Point p"),
    @NamedQuery(name = "Point.findByIdPoint", query = "SELECT p FROM Point p WHERE p.pointPK.idPoint = :idPoint"),
    @NamedQuery(name = "Point.findByIdRoute", query = "SELECT p FROM Point p WHERE p.pointPK.idRoute = :idRoute"),
    @NamedQuery(name = "Point.findByLatitude", query = "SELECT p FROM Point p WHERE p.latitude = :latitude"),
    @NamedQuery(name = "Point.findByLongitude", query = "SELECT p FROM Point p WHERE p.longitude = :longitude"),
    @NamedQuery(name = "Point.findByAddressname", query = "SELECT p FROM Point p WHERE p.addressname = :addressname")})
public class Point implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected PointPK pointPK;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "LATITUDE")
    private BigDecimal latitude;
    @Column(name = "LONGITUDE")
    private BigDecimal longitude;
    @Size(max = 600)
    @Column(name = "ADDRESSNAME")
    private String addressname;
    @JoinColumn(name = "ID_ROUTE", referencedColumnName = "ID_ROUTE", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Route route;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "point", fetch = FetchType.LAZY)
    private List<PointStatus> pointStatusList;

    public Point() {
    }

    public Point(PointPK pointPK) {
        this.pointPK = pointPK;
    }

    public Point(BigInteger idPoint, BigInteger idRoute) {
        this.pointPK = new PointPK(idPoint, idRoute);
    }

    public PointPK getPointPK() {
        return pointPK;
    }

    public void setPointPK(PointPK pointPK) {
        this.pointPK = pointPK;
    }

    public BigDecimal getLatitude() {
        return latitude;
    }

    public void setLatitude(BigDecimal latitude) {
        this.latitude = latitude;
    }

    public BigDecimal getLongitude() {
        return longitude;
    }

    public void setLongitude(BigDecimal longitude) {
        this.longitude = longitude;
    }

    public String getAddressname() {
        return addressname;
    }

    public void setAddressname(String addressname) {
        this.addressname = addressname;
    }

    public Route getRoute() {
        return route;
    }

    public void setRoute(Route route) {
        this.route = route;
    }

    @XmlTransient
    public List<PointStatus> getPointStatusList() {
        return pointStatusList;
    }

    public void setPointStatusList(List<PointStatus> pointStatusList) {
        this.pointStatusList = pointStatusList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (pointPK != null ? pointPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Point)) {
            return false;
        }
        Point other = (Point) object;
        if ((this.pointPK == null && other.pointPK != null) || (this.pointPK != null && !this.pointPK.equals(other.pointPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.Point[ pointPK=" + pointPK + " ]";
    }
    
}
